<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/modules/mac/csma.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00426.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">csma.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode:c++ -*- ********************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> * file:        csma.h</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment">  * author:     Jerome Rousselot, Marcel Steine, Amre El-Hoiydi,</span>
<a name="l00005"></a>00005 <span class="comment"> *        Marc Loebbers, Yosia Hadisusanto</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * copyright: (C) 2007-2009 CSEM SA</span>
<a name="l00008"></a>00008 <span class="comment"> *        (C) 2009 T.U. Eindhoven</span>
<a name="l00009"></a>00009 <span class="comment"> *        (C) 2004 Telecommunication Networks Group (TKN) at</span>
<a name="l00010"></a>00010 <span class="comment"> *              Technische Universitaet Berlin, Germany.</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> *              This program is free software; you can redistribute it</span>
<a name="l00013"></a>00013 <span class="comment"> *              and/or modify it under the terms of the GNU General Public</span>
<a name="l00014"></a>00014 <span class="comment"> *              License as published by the Free Software Foundation; either</span>
<a name="l00015"></a>00015 <span class="comment"> *              version 2 of the License, or (at your option) any later</span>
<a name="l00016"></a>00016 <span class="comment"> *              version.</span>
<a name="l00017"></a>00017 <span class="comment"> *              For further information see file COPYING</span>
<a name="l00018"></a>00018 <span class="comment"> *              in the top level directory</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * Funding: This work was partially financed by the European Commission under the</span>
<a name="l00021"></a>00021 <span class="comment"> * Framework 6 IST Project &quot;Wirelessly Accessible Sensor Populations&quot;</span>
<a name="l00022"></a>00022 <span class="comment"> * (WASP) under contract IST-034963.</span>
<a name="l00023"></a>00023 <span class="comment"> ***************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> * part of:    Modifications to the MF-2 framework by CSEM</span>
<a name="l00025"></a>00025 <span class="comment"> **************************************************************************/</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#ifndef csma_H</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define csma_H</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;list&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;MiXiMDefs.h&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;BaseMacLayer.h&quot;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;DroppedPacket.h&quot;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="keyword">class </span>MacPkt;
<a name="l00040"></a>00040 
<a name="l00055"></a><a class="code" href="a00067.html">00055</a> <span class="keyword">class </span>MIXIM_API <a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a> : <span class="keyword">public</span> <a class="code" href="a00026.html" title="A very simple MAC module template which provides de- and encapsulation of messages using the standard...">BaseMacLayer</a>
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057   <span class="keyword">public</span>:
<a name="l00058"></a>00058   <a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a>()
<a name="l00059"></a>00059     : <a class="code" href="a00026.html" title="A very simple MAC module template which provides de- and encapsulation of messages using the standard...">BaseMacLayer</a>()
<a name="l00060"></a>00060     , nbTxFrames(0)
<a name="l00061"></a>00061     , nbRxFrames(0)
<a name="l00062"></a>00062     , nbMissedAcks(0)
<a name="l00063"></a>00063     , nbRecvdAcks(0)
<a name="l00064"></a>00064     , nbDroppedFrames(0)
<a name="l00065"></a>00065     , nbTxAcks(0)
<a name="l00066"></a>00066     , nbDuplicates(0)
<a name="l00067"></a>00067     , nbBackoffs(0)
<a name="l00068"></a>00068     , backoffValues(0)
<a name="l00069"></a>00069     , stats(<span class="keyword">false</span>)
<a name="l00070"></a>00070     , trace(<span class="keyword">false</span>)
<a name="l00071"></a>00071     , backoffTimer(NULL), ccaTimer(NULL), sifsTimer(NULL), rxAckTimer(NULL)
<a name="l00072"></a>00072     , macState(IDLE_1)
<a name="l00073"></a>00073     , status(STATUS_OK)
<a name="l00074"></a>00074     , sifs()
<a name="l00075"></a>00075     , macAckWaitDuration()
<a name="l00076"></a>00076     , transmissionAttemptInterruptedByRx(<span class="keyword">false</span>)
<a name="l00077"></a>00077     , ccaDetectionTime()
<a name="l00078"></a>00078     , rxSetupTime()
<a name="l00079"></a>00079     , aTurnaroundTime()
<a name="l00080"></a>00080     , macMaxCSMABackoffs(0)
<a name="l00081"></a>00081     , macMaxFrameRetries(0)
<a name="l00082"></a>00082     , aUnitBackoffPeriod()
<a name="l00083"></a>00083     , useMACAcks(<span class="keyword">false</span>)
<a name="l00084"></a>00084     , backoffMethod(CONSTANT)
<a name="l00085"></a>00085     , macMinBE(0)
<a name="l00086"></a>00086     , macMaxBE(0)
<a name="l00087"></a>00087     , initialCW(0)
<a name="l00088"></a>00088     , txPower(0)
<a name="l00089"></a>00089     , NB(0)
<a name="l00090"></a>00090     , macQueue()
<a name="l00091"></a>00091     , queueLength(0)
<a name="l00092"></a>00092     , txAttempts(0)
<a name="l00093"></a>00093     , bitrate(0)
<a name="l00094"></a>00094     , droppedPacket()
<a name="l00095"></a>00095     , nicId(-1)
<a name="l00096"></a>00096     , ackLength(0)
<a name="l00097"></a>00097     , ackMessage(NULL)
<a name="l00098"></a>00098     , SeqNrParent()
<a name="l00099"></a>00099     , SeqNrChild()
<a name="l00100"></a>00100   {}
<a name="l00101"></a>00101 
<a name="l00102"></a>00102   <span class="keyword">virtual</span> ~<a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a>();
<a name="l00103"></a>00103 
<a name="l00105"></a>00105     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a61c82dc3b225eac37f7fa9936c28c2c3" title="Initialization of the module and some variables.">initialize</a>(<span class="keywordtype">int</span>);
<a name="l00106"></a>00106 
<a name="l00108"></a>00108     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00025.html#a5ab11502dbeeea89693d29841376a2f7" title="Called when the simulation has finished.">finish</a>();
<a name="l00109"></a>00109 
<a name="l00111"></a>00111     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a413375cec02b990a521b62086a02264c">handleLowerMsg</a>(cMessage*);
<a name="l00112"></a>00112 
<a name="l00114"></a>00114     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a6de2ca07018de313a7147a03e6d77bff" title="Handle messages comming from the network layer.">handleUpperMsg</a>(cMessage*);
<a name="l00115"></a>00115 
<a name="l00117"></a>00117     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#add5277c1a60dab10db40c8d9641e48c4" title="Handle self messages such as timer...">handleSelfMsg</a>(cMessage*);
<a name="l00118"></a>00118 
<a name="l00120"></a>00120     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00026.html#a796d456d593dfab3188b37e506dd76a8" title="Handle control messages from lower layer.">handleLowerControl</a>(cMessage *msg);
<a name="l00121"></a>00121 
<a name="l00122"></a>00122   <span class="keyword">protected</span>:
<a name="l00123"></a>00123     <span class="keyword">typedef</span> std::list&lt;macpkt_ptr_t&gt; MacQueue;
<a name="l00124"></a>00124 
<a name="l00127"></a>00127   <span class="keywordtype">long</span> nbTxFrames;
<a name="l00128"></a>00128   <span class="keywordtype">long</span> nbRxFrames;
<a name="l00129"></a>00129   <span class="keywordtype">long</span> nbMissedAcks;
<a name="l00130"></a>00130   <span class="keywordtype">long</span> nbRecvdAcks;
<a name="l00131"></a>00131   <span class="keywordtype">long</span> nbDroppedFrames;
<a name="l00132"></a>00132   <span class="keywordtype">long</span> nbTxAcks;
<a name="l00133"></a>00133   <span class="keywordtype">long</span> nbDuplicates;
<a name="l00134"></a>00134   <span class="keywordtype">long</span> nbBackoffs;
<a name="l00135"></a>00135   <span class="keywordtype">double</span> backoffValues;
<a name="l00139"></a><a class="code" href="a00067.html#a1b4834898677ae70f70e336a5af6bea4">00139</a>   <span class="keywordtype">bool</span> <a class="code" href="a00067.html#a1b4834898677ae70f70e336a5af6bea4" title="Records general statistics?">stats</a>;
<a name="l00141"></a><a class="code" href="a00067.html#af0459af5600cded297d8baaebf93270a">00141</a>   <span class="keywordtype">bool</span> <a class="code" href="a00067.html#af0459af5600cded297d8baaebf93270a" title="Record out put vectors?">trace</a>;
<a name="l00142"></a>00142 
<a name="l00146"></a><a class="code" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165">00146</a>     <span class="keyword">enum</span> <a class="code" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165" title="MAC states see states diagram.">t_mac_states</a> {
<a name="l00147"></a>00147         IDLE_1=1,
<a name="l00148"></a>00148         BACKOFF_2,
<a name="l00149"></a>00149         CCA_3,
<a name="l00150"></a>00150         TRANSMITFRAME_4,
<a name="l00151"></a>00151         WAITACK_5,
<a name="l00152"></a>00152         WAITSIFS_6,
<a name="l00153"></a>00153         TRANSMITACK_7
<a name="l00154"></a>00154 
<a name="l00155"></a>00155     };
<a name="l00156"></a>00156 
<a name="l00157"></a>00157     <span class="comment">/*************************************************************/</span>
<a name="l00158"></a>00158     <span class="comment">/****************** TYPES ************************************/</span>
<a name="l00159"></a>00159     <span class="comment">/*************************************************************/</span>
<a name="l00160"></a>00160 
<a name="l00162"></a><a class="code" href="a00067.html#ab33d8c1261a8e13f526a63364232a19e">00162</a>     <span class="keyword">enum</span> <a class="code" href="a00067.html#ab33d8c1261a8e13f526a63364232a19e" title="Kinds for timer messages.">t_mac_timer</a> {
<a name="l00163"></a>00163       TIMER_NULL=0,
<a name="l00164"></a>00164       TIMER_BACKOFF,
<a name="l00165"></a>00165       TIMER_CCA,
<a name="l00166"></a>00166       TIMER_SIFS,
<a name="l00167"></a>00167       TIMER_RX_ACK,
<a name="l00168"></a>00168     };
<a name="l00169"></a>00169 
<a name="l00172"></a>00172     cMessage * backoffTimer, * ccaTimer, * sifsTimer, * rxAckTimer;
<a name="l00177"></a><a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">00177</a>     <span class="keyword">enum</span> <a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> {
<a name="l00178"></a>00178       EV_SEND_REQUEST=1,                   <span class="comment">// 1, 11, 20, 21, 22</span>
<a name="l00179"></a>00179       EV_TIMER_BACKOFF,                    <span class="comment">// 2, 7, 14, 15</span>
<a name="l00180"></a>00180       EV_FRAME_TRANSMITTED,                <span class="comment">// 4, 19</span>
<a name="l00181"></a>00181       EV_ACK_RECEIVED,                     <span class="comment">// 5</span>
<a name="l00182"></a>00182       EV_ACK_TIMEOUT,                      <span class="comment">// 12</span>
<a name="l00183"></a>00183       EV_FRAME_RECEIVED,                   <span class="comment">// 15, 26</span>
<a name="l00184"></a>00184       EV_DUPLICATE_RECEIVED,
<a name="l00185"></a>00185       EV_TIMER_SIFS,                       <span class="comment">// 17</span>
<a name="l00186"></a>00186       EV_BROADCAST_RECEIVED,       <span class="comment">// 23, 24</span>
<a name="l00187"></a>00187       EV_TIMER_CCA
<a name="l00188"></a>00188     };
<a name="l00189"></a>00189 
<a name="l00191"></a><a class="code" href="a00067.html#ae008d14977310cab31c835efffcb02e7">00191</a>     <span class="keyword">enum</span> <a class="code" href="a00067.html#ae008d14977310cab31c835efffcb02e7" title="Types for frames sent by the CSMA.">t_csma_frame_types</a> {
<a name="l00192"></a>00192       DATA,
<a name="l00193"></a>00193       ACK
<a name="l00194"></a>00194     };
<a name="l00195"></a>00195 
<a name="l00196"></a>00196     <span class="keyword">enum</span> t_mac_carrier_sensed {
<a name="l00197"></a>00197       CHANNEL_BUSY=1,
<a name="l00198"></a>00198       CHANNEL_FREE
<a name="l00199"></a>00199     } ;
<a name="l00200"></a>00200 
<a name="l00201"></a>00201     <span class="keyword">enum</span> t_mac_status {
<a name="l00202"></a>00202       STATUS_OK=1,
<a name="l00203"></a>00203       STATUS_ERROR,
<a name="l00204"></a>00204       STATUS_RX_ERROR,
<a name="l00205"></a>00205       STATUS_RX_TIMEOUT,
<a name="l00206"></a>00206       STATUS_FRAME_TO_PROCESS,
<a name="l00207"></a>00207       STATUS_NO_FRAME_TO_PROCESS,
<a name="l00208"></a>00208       STATUS_FRAME_TRANSMITTED
<a name="l00209"></a>00209     };
<a name="l00210"></a>00210 
<a name="l00212"></a><a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021d">00212</a>     <span class="keyword">enum</span> <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021d" title="The different back-off methods.">backoff_methods</a> {
<a name="l00214"></a><a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5">00214</a>       CONSTANT = 0,
<a name="l00216"></a><a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421">00216</a>       <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421" title="Linear increasing back-off time.">LINEAR</a>,
<a name="l00218"></a><a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549">00218</a>       <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549" title="Exponentially increasing back-off time.">EXPONENTIAL</a>,
<a name="l00219"></a>00219     };
<a name="l00220"></a>00220 
<a name="l00222"></a><a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75">00222</a>     <a class="code" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165" title="MAC states see states diagram.">t_mac_states</a> <a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75" title="keep track of MAC state">macState</a>;
<a name="l00223"></a>00223     t_mac_status status;
<a name="l00224"></a>00224 
<a name="l00230"></a><a class="code" href="a00067.html#a4c4485a6c261026fbb39eee038c61d35">00230</a>     simtime_t <a class="code" href="a00067.html#a4c4485a6c261026fbb39eee038c61d35" title="Maximum time between a packet and its ACK.">sifs</a>;
<a name="l00231"></a>00231 
<a name="l00233"></a><a class="code" href="a00067.html#ac9f2b5914cfbdd9763531913f0756eb7">00233</a>     simtime_t <a class="code" href="a00067.html#ac9f2b5914cfbdd9763531913f0756eb7" title="The amount of time the MAC waits for the ACK of a packet.">macAckWaitDuration</a>;
<a name="l00234"></a>00234 
<a name="l00235"></a>00235     <span class="keywordtype">bool</span> transmissionAttemptInterruptedByRx;
<a name="l00237"></a><a class="code" href="a00067.html#ae54073ef32d73822112cbc3ccfd5cd20">00237</a>     simtime_t <a class="code" href="a00067.html#ae54073ef32d73822112cbc3ccfd5cd20" title="CCA detection time.">ccaDetectionTime</a>;
<a name="l00239"></a><a class="code" href="a00067.html#a2de1e148306253a3b7a33ae2c47201dc">00239</a>     simtime_t <a class="code" href="a00067.html#a2de1e148306253a3b7a33ae2c47201dc" title="Time to setup radio from sleep to Rx state.">rxSetupTime</a>;
<a name="l00241"></a><a class="code" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69">00241</a>     simtime_t <a class="code" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69" title="Time to switch radio from Rx to Tx state.">aTurnaroundTime</a>;
<a name="l00243"></a><a class="code" href="a00067.html#a8651bf006f28d69523c43d2aea774f7c">00243</a>     <span class="keywordtype">int</span> <a class="code" href="a00067.html#a8651bf006f28d69523c43d2aea774f7c" title="maximum number of backoffs before frame drop">macMaxCSMABackoffs</a>;
<a name="l00245"></a><a class="code" href="a00067.html#af7b3c7c2d0028579026dd17a267d4a72">00245</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="a00067.html#af7b3c7c2d0028579026dd17a267d4a72" title="maximum number of frame retransmissions without ack">macMaxFrameRetries</a>;
<a name="l00247"></a><a class="code" href="a00067.html#a63f8c5595546dedb2d2f779b2f88fc7b">00247</a>     simtime_t <a class="code" href="a00067.html#a63f8c5595546dedb2d2f779b2f88fc7b" title="base time unit for calculating backoff durations">aUnitBackoffPeriod</a>;
<a name="l00249"></a><a class="code" href="a00067.html#a51f34d63f063978e4077e290ed96579d">00249</a>     <span class="keywordtype">bool</span> <a class="code" href="a00067.html#a51f34d63f063978e4077e290ed96579d" title="Stores if the MAC expects Acks for Unicast packets.">useMACAcks</a>;
<a name="l00250"></a>00250 
<a name="l00252"></a><a class="code" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0">00252</a>     <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021d" title="The different back-off methods.">backoff_methods</a> <a class="code" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0" title="Defines the backoff method to be used.">backoffMethod</a>;
<a name="l00253"></a>00253 
<a name="l00258"></a><a class="code" href="a00067.html#aec2a85f71170231d175a7e5f453488bf">00258</a>   <span class="keywordtype">int</span> <a class="code" href="a00067.html#aec2a85f71170231d175a7e5f453488bf" title="Minimum backoff exponent. Only used for exponential backoff method.">macMinBE</a>;
<a name="l00263"></a><a class="code" href="a00067.html#a07d8675d0999963f22caa47b90feee7b">00263</a>   <span class="keywordtype">int</span> <a class="code" href="a00067.html#a07d8675d0999963f22caa47b90feee7b" title="Maximum backoff exponent. Only used for exponential backoff method.">macMaxBE</a>;
<a name="l00264"></a>00264 
<a name="l00267"></a><a class="code" href="a00067.html#aa2d96f20753eff74aa1b9b3251523d24">00267</a>   <span class="keywordtype">double</span> <a class="code" href="a00067.html#aa2d96f20753eff74aa1b9b3251523d24" title="initial contention window size Only used for linear and constant backoff method.">initialCW</a>;
<a name="l00268"></a>00268 
<a name="l00270"></a><a class="code" href="a00067.html#a45229ade2d3472af4c427384443fbd9f">00270</a>     <span class="keywordtype">double</span> <a class="code" href="a00067.html#a45229ade2d3472af4c427384443fbd9f" title="The power (in mW) to transmit with.">txPower</a>;
<a name="l00271"></a>00271 
<a name="l00273"></a><a class="code" href="a00067.html#aa01f7215a8fccd726da22a0721994580">00273</a>     <span class="keywordtype">int</span> <a class="code" href="a00067.html#aa01f7215a8fccd726da22a0721994580" title="number of backoff performed until now for current frame">NB</a>;
<a name="l00274"></a>00274 
<a name="l00277"></a><a class="code" href="a00067.html#ac75e73d1a95881bcdcb125f13876e996">00277</a>     MacQueue <a class="code" href="a00067.html#ac75e73d1a95881bcdcb125f13876e996" title="A queue to store packets from upper layer in case another packet is still waiting for transmission...">macQueue</a>;
<a name="l00278"></a>00278 
<a name="l00280"></a><a class="code" href="a00067.html#a6c5dda6e483befcd9166dd2d1c099ff1">00280</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a6c5dda6e483befcd9166dd2d1c099ff1" title="length of the queue">queueLength</a>;
<a name="l00281"></a>00281 
<a name="l00286"></a><a class="code" href="a00067.html#a6249492db8b5f2240aefd33ba1bbf04e">00286</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a6249492db8b5f2240aefd33ba1bbf04e" title="count the number of tx attempts">txAttempts</a>;
<a name="l00287"></a>00287 
<a name="l00289"></a><a class="code" href="a00067.html#af881ff622dc82a06fc14008d67a0d084">00289</a>     <span class="keywordtype">double</span> <a class="code" href="a00067.html#af881ff622dc82a06fc14008d67a0d084" title="the bit rate at which we transmit">bitrate</a>;
<a name="l00290"></a>00290 
<a name="l00292"></a><a class="code" href="a00067.html#ab8c7954aa7b5dc31268b3673a358e9f9">00292</a>     <a class="code" href="a00088.html" title="May be published by MAC lyer to indicate why a packet was dropped.">DroppedPacket</a> <a class="code" href="a00067.html#ab8c7954aa7b5dc31268b3673a358e9f9" title="Inspect reasons for dropped packets.">droppedPacket</a>;
<a name="l00293"></a>00293 
<a name="l00295"></a><a class="code" href="a00067.html#a384d9dce68d3db1b258369095e5b12a4">00295</a>     <span class="keywordtype">int</span> <a class="code" href="a00067.html#a384d9dce68d3db1b258369095e5b12a4" title="publish dropped packets nic wide">nicId</a>;
<a name="l00296"></a>00296 
<a name="l00298"></a><a class="code" href="a00067.html#a3fba7040140a46c800ea94560fe0113a">00298</a>     <span class="keywordtype">int</span> <a class="code" href="a00067.html#a3fba7040140a46c800ea94560fe0113a" title="The bit length of the ACK packet.">ackLength</a>;
<a name="l00299"></a>00299 
<a name="l00300"></a>00300 <span class="keyword">protected</span>:
<a name="l00301"></a>00301   <span class="comment">// FSM functions</span>
<a name="l00302"></a>00302   <span class="keywordtype">void</span> fsmError(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00303"></a>00303   <span class="keywordtype">void</span> executeMac(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00304"></a>00304   <span class="keywordtype">void</span> updateStatusIdle(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00305"></a>00305   <span class="keywordtype">void</span> updateStatusBackoff(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00306"></a>00306   <span class="keywordtype">void</span> updateStatusCCA(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00307"></a>00307   <span class="keywordtype">void</span> updateStatusTransmitFrame(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00308"></a>00308   <span class="keywordtype">void</span> updateStatusWaitAck(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00309"></a>00309   <span class="keywordtype">void</span> updateStatusSIFS(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00310"></a>00310   <span class="keywordtype">void</span> updateStatusTransmitAck(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00311"></a>00311   <span class="keywordtype">void</span> updateStatusNotIdle(cMessage *msg);
<a name="l00312"></a>00312   <span class="keywordtype">void</span> manageQueue();
<a name="l00313"></a>00313   <span class="keywordtype">void</span> updateMacState(<a class="code" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165" title="MAC states see states diagram.">t_mac_states</a> newMacState);
<a name="l00314"></a>00314 
<a name="l00315"></a>00315   <span class="keywordtype">void</span> attachSignal(macpkt_ptr_t mac, simtime_t_cref startTime);
<a name="l00316"></a>00316   <span class="keywordtype">void</span> manageMissingAck(<a class="code" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2" title="MAC state machine events. See state diagram.">t_mac_event</a> event, cMessage *msg);
<a name="l00317"></a>00317   <span class="keywordtype">void</span> startTimer(<a class="code" href="a00067.html#ab33d8c1261a8e13f526a63364232a19e" title="Kinds for timer messages.">t_mac_timer</a> timer);
<a name="l00318"></a>00318 
<a name="l00319"></a>00319   <span class="keyword">virtual</span> simtime_t scheduleBackoff();
<a name="l00320"></a>00320 
<a name="l00321"></a>00321   <span class="keyword">virtual</span> cPacket *<a class="code" href="a00026.html#a998b4c4c56074a354b50f8c4fc5d6d4c" title="decapsulate the network message from the MacPkt">decapsMsg</a>(macpkt_ptr_t macPkt);
<a name="l00322"></a>00322   macpkt_ptr_t ackMessage;
<a name="l00323"></a>00323 
<a name="l00324"></a>00324   <span class="comment">//sequence number for sending, map for the general case with more senders</span>
<a name="l00325"></a>00325   <span class="comment">//also in initialisation phase multiple potential parents</span>
<a name="l00326"></a>00326   std::map&lt;LAddress::L2Type, unsigned long&gt; SeqNrParent; <span class="comment">//parent -&gt; sequence number</span>
<a name="l00327"></a>00327 
<a name="l00328"></a>00328   <span class="comment">//sequence numbers for receiving</span>
<a name="l00329"></a>00329   std::map&lt;LAddress::L2Type, unsigned long&gt; SeqNrChild; <span class="comment">//child -&gt; sequence number</span>
<a name="l00330"></a>00330 
<a name="l00331"></a>00331 <span class="keyword">private</span>:
<a name="l00334"></a>00334     <a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a>(<span class="keyword">const</span> <a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a>&amp;);
<a name="l00337"></a>00337     <a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a>&amp; <a class="code" href="a00026.html#aac78343ae4c96940669323e51ec09ada" title="Assignment operator is not allowed.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00067.html" title="Generic CSMA Mac-Layer.">csma</a>&amp;);
<a name="l00338"></a>00338 
<a name="l00339"></a>00339 };
<a name="l00340"></a>00340 
<a name="l00341"></a>00341 <span class="preprocessor">#endif</span>
<a name="l00342"></a>00342 <span class="preprocessor"></span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>csma.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
